package com.youdu.manager;


import com.youdu.module.user.User;

/**
 * @author renzhiqiang
 * @description 单例管理登陆用户信息
 * @date 2015年8月19日
 */
public class UserManager {

    private volatile static UserManager sUserManager = null;
    private User user = null;

    public static UserManager getInstance() {

        if (sUserManager == null) {
            synchronized (UserManager.class) {
                if (sUserManager == null) {
                    sUserManager = new UserManager();
                }
            }
        }

        return sUserManager;
    }

    /**
     * init the user
     *
     * @param user
     */
    public void setUser(User user) {

        this.user = user;
    }

    public boolean hasLogined() {

        return user == null ? false : true;
    }

    /**
     * has user info
     *
     * @return
     */
    public User getUser() {

        return this.user;
    }

    /**
     * remove the user info
     */
    public void removeUser() {

        this.user = null;
    }
}
